package charTest;

import org.apache.commons.collections.map.HashedMap;
import org.junit.Test;

import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;

/**
 * 输入12 返回十二
 * 输入24 返回二十四
 */
public class test3 {
    public void test(String demo) {
        Pattern.matches("^[]0-9]{1,}$","");
        StringBuffer s = new StringBuffer();
        Map<Character,String> map = new HashMap<Character,String>();
        map.put('1',"一");
        map.put('2',"二");
        map.put('3',"三");
        map.put('4',"四");
        map.put('5',"五");
        map.put('6',"六");
        map.put('7',"七");
        map.put('8',"八");
        map.put('9',"九");
        map.put('0',"十");
        if (Pattern.matches("^[0-9]{1,}$", demo)) {

            char[] de = demo.toCharArray();
            if(de.length ==1){
                s.append(map.get(de[0]));
            }else if(de.length ==2 && de[0] =='1'){
                s.append(map.get('0'));
                s.append(map.get(de[1]));

            }else{
                s.append(map.get(de[0]));
                s.append(map.get('0'));
                s.append(map.get(de[1]));
            }

        }else{
            s.append("false");
        }

        System.out.println("demo=" + s);
    }

  /*  public static void main(String[] args) {

        test3 test3 = new test3();
        test3.test("80");
    }*/
}